from pyexpat import model
from langchain.agents import create_agent
from langchain_openai import ChatOpenAI

def send_email(to: str, subject: str, body: str):
    """Send an email"""
    email = {
        "to": to,
        "subject": subject,
        "body": body
    }

    return f"Email sent to {to}"

llm = ChatOpenAI(
    model="qwen-plus",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1/",
    api_key="sk-4adf3d4278414c21abf8f26fa9aaa267", 
    temperature=0,
    streaming=True  # 启用流式输出
)

agent = create_agent(
    model=llm,
    tools=[send_email],
    system_prompt="You are an email assistant. Always use the send_email tool.",
)